#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int min(int a, int b)
{
	return a < b ? a : b;
}

int main() {
	int a = 0, b = 0, c = 0;
	scanf("%d %d", &a, &b);
	for (int i = 1; i <= min(a, b); i++)
	{
		if (a % i == 0 && b % i == 0)
			c = i;
	}
	printf("%d", c);
	return 0;
}